package com.hjb.service.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hjb.service.TestService;
import com.hjb.service.Wechat.WechatService;
import com.hjb.service.annotation.LogInfo;
import com.hjb.service.annotation.LogType;
import com.hjb.service.domain.siteuser.SiteUser;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * 测试接口
 */
@RestController
@RequestMapping("/test")
@Api(value="/test",description="测试接口"	)
public class TestController {
	private Logger log = LoggerFactory.getLogger(getClass());

	@Autowired
	private TestService testService;
	@Autowired
	private WechatService wxUtilService;
	/**
	 * 获取银行code
	 * @param request
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	@LogInfo(logType = LogType.查询, operationContent = "测试接口")
	@PostMapping("/test")
	@ResponseBody
	@ApiOperation("测试接口")
	@ApiImplicitParams({ 
		@ApiImplicitParam(paramType = "query", dataType = "String", name = "userid", value = "用户ID", required = false), 
		@ApiImplicitParam(paramType = "query", dataType = "String", name = "username", value = "用户名", required = false), 
		@ApiImplicitParam(paramType = "query", dataType = "Integer", name = "pageNum", value = "页面", required = true), 
		@ApiImplicitParam(paramType = "query", dataType = "Integer", name = "pageSize", value = "页面大小", required = true) 
		})
	public ResponseEntity getBankCode(
	        @RequestParam(value = "userid",required = false)String userid,
	        @RequestParam(value = "username",required = false)String username,
	        @RequestParam(value = "pageNum",required = true)Integer pageNum,
	        @RequestParam(value = "pageSize",required = true)Integer pageSize
	        ){
		
		Page page = PageHelper.startPage(pageNum, pageSize);
		
		List<SiteUser> list = testService.gettest(userid, username);
		
		return ResponseEntity.ok(list);
	}

	@LogInfo(logType = LogType.查询, operationContent = "测试获取二维码")
	@PostMapping("/getErweima")
	@ResponseBody
	@ApiOperation("测试获取二维码")
	@ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType = "String", name = "phonenumber", value = "手机号", required = false)})
	public ResponseEntity getErweima(String phonenumber){
		wxUtilService.getErweimaTicket(phonenumber);
		return  ResponseEntity.ok("1");
	}
}
